#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
long long n, m, V, L;
long long d[MAXN];
long long a[MAXN];
long long v[MAXN];
long long spd[MAXN];
void doit()
{
    cin >> n >> m >> L >> V;
    for (int i = 1; i <= n; ++i)
    {
        cin >> d[i] >> v[i] >> a[i];
    }
    for (int i = 1; i <= m; ++i)
    {
        cin >> spd[i];
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (d[i] > spd[m]) continue;
        else
        {
            int vs2 = v[i] * v[i] + 2 * a[i] * (spd[m] - d[i]);
            if (vs2 > V * V) cnt++;
        }
    }
    cout << cnt << ' ';
    if (cnt == 0) cout << m << endl;
    else cout << m - 1 << endl;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int T;
    cin >> T;
    for (int p = 1; p <= T; ++p)
    {
        doit();
    }
    return 0;
}
